package cn.edu.mju.property.web.controller;

import cn.edu.mju.property.entity.Complaint;
import cn.edu.mju.property.service.impl.ComplaintServiceImpl;
import cn.edu.mju.property.service.ComplaintService;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/FindComplaint")
public class FindComplaint extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setContentType("application/json; charset=UTF-8");
        response.setDateHeader("expries", -1);
        response.setHeader("Cache-Control", "no-cache");
        response.setHeader("Pragma", "no-cache");

        String id = request.getParameter("id");

        ComplaintService service =new ComplaintServiceImpl();
        Complaint complaint = service.findComplaint(id);
        response.getWriter().write(JSON.toJSONString(complaint));



    }
}
